<!-- build time:Tue Dec 17 2019 19:26:45 GMT+0800 (GMT+08:00) --><!doctype html><html class="theme-next mist" lang="zh-Hans"><head><meta name="generator" content="Hexo 3.8.0"><meta name="google-site-verification" content="7Tau9WyVgxnsEY9oYedu9g0U6_8akOX3wiKbaYcrg9A"><meta name="baidu-site-verification" content="EVwLiaxdxX"><link href="/css/xps13.css" rel="stylesheet" type="text/css"><link href="/css/message.css" rel="stylesheet" type="text/css"><script type="text/javascript" src="/js/jquery-1.11.3.min.js"></script><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css"><link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css"><meta name="keywords" content="DataBase,Oracle,Oracle 11g,"><link rel="alternate" href="/atom.xml" title="MrBird" type="application/atom+xml"><link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1"><meta name="description" content="SQLPlus是一个被DBA和开发人员广泛使用的功能强大的Oracle工具，可以在各个平台上拥有操作的一致性。SQLPlus可以执行输入的SQL语句和SQL文件，通过SQLPlus可以和数据库进行对话。以下例子基于Oracle 11g。"><meta name="keywords" content="DataBase,Oracle,Oracle 11g"><meta property="og:type" content="article"><meta property="og:title" content="Oracle SQLPlus命令"><meta property="og:url" content="http://mrbird.cc/Oracle-SQLPlus命令.html"><meta property="og:site_name" content="MrBird"><meta property="og:description" content="SQLPlus是一个被DBA和开发人员广泛使用的功能强大的Oracle工具，可以在各个平台上拥有操作的一致性。SQLPlus可以执行输入的SQL语句和SQL文件，通过SQLPlus可以和数据库进行对话。以下例子基于Oracle 11g。"><meta property="og:locale" content="zh-Hans"><meta property="og:image" content="http://mrbird.cc/img/mrbird_photo_20171105144257.png"><meta property="og:updated_time" content="2019-10-28T12:14:46.258Z"><meta name="twitter:card" content="summary"><meta name="twitter:title" content="Oracle SQLPlus命令"><meta name="twitter:description" content="SQLPlus是一个被DBA和开发人员广泛使用的功能强大的Oracle工具，可以在各个平台上拥有操作的一致性。SQLPlus可以执行输入的SQL语句和SQL文件，通过SQLPlus可以和数据库进行对话。以下例子基于Oracle 11g。"><meta name="twitter:image" content="http://mrbird.cc/img/mrbird_photo_20171105144257.png"><script type="text/javascript" id="hexo.configurations">var NexT=window.NexT||{},CONFIG={root:"/",scheme:"Mist",sidebar:{position:"left",display:"always",offset:12,offset_float:0,b2t:!1,scrollpercent:!1},fancybox:!1,motion:!1}</script><title>Oracle SQLPlus命令 | MrBird</title></head><body ondragstart="return!1" class="animsition" lang="zh-Hans" style="overflow-x:hidden;padding-right:280px"><script type="text/javascript" src="/js/mo.min.js"></script><style>@media (min-width:768px) and (max-width:991px){body .header-innerr{width:700px!important}}.header-innerr{margin:0 auto;padding:100px 0 70px;width:880px}@media (min-width:1600px){.container .header-innerr{width:1200px}}.header-innerr{position:relative}.header-innerr{padding:20px 0 0}.header-innerr:after,.header-innerr:before{content:" ";display:table}.header-innerr:after{clear:both}@media (max-width:767px){.header-innerr{width:auto;padding:10px;margin-bottom:-20px}}</style><div class="container sidebar-position-left page-post-detail"><div class="headband"></div><header id="header" class="header"><div class="header-inner"><div class="site-brand-wrapper"><div class="site-meta"><link href="https://fonts.font.im/css?family=Merienda" rel="stylesheet"><div class="custom-logo-site-title"><a href="/" class="brand" rel="start"><span class="logo-line-before"><i></i></span> <span class="site-title" style="font-family:Merienda;font-size:1.3rem">MrBird</span> <span class="logo-line-after"><i></i></span></a></div><p class="site-subtitle"></p></div><div class="site-nav-toggle"><button><span class="btn-bar"></span> <span class="btn-bar"></span> <span class="btn-bar"></span></button></div></div><nav class="site-nav"><ul id="menu" class="menu"><li class="menu-item menu-item-home"><a href="/" rel="section">HOME</a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section">ARCHIVES</a></li><li class="menu-item menu-item-tags"><a href="/tags/" rel="section">TAGS</a></li><li class="menu-item menu-item-friends"><a href="/friends/" rel="section">FRIENDS</a></li><div class="sidebar-toggle" style="display:none"><div class="sidebar-toggle-line-wrap"><span class="sidebar-toggle-line sidebar-toggle-line-first"></span> <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span> <span class="sidebar-toggle-line sidebar-toggle-line-last"></span></div></div></ul><div class="site-search"><div class="popup search-popup local-search-popup"><div class="local-search-header clearfix"><span class="search-icon"><i class="fa fa-search"></i> </span><span class="popup-btn-close"><i class="fa fa-times-circle"></i></span><div class="local-search-input-wrapper"><input autocomplete="off" placeholder="Search" spellcheck="false" type="text" id="local-search-input"></div></div><div id="local-search-result"></div></div></div></nav></div><div class="header-innerr"><div class="note info" style="margin:0;letter-spacing:.15px">🐤手把手教你搭建<strong>Spring Cloud微服务权限系统</strong>（从零到部署）：<a style="color:#40dab2;font-weight:600" href="https://www.kancloud.cn/mrbird/spring-cloud" target="_blank">https://www.kancloud.cn/mrbird/spring-cloud</a></div></div></header><main id="main" class="main"><div class="main-inner"><div class="content-wrap"><div id="content" class="content"><div id="posts" class="posts-expand"><article class="post post-type-normal" itemscope itemtype="http://schema.org/Article"><link itemprop="mainEntityOfPage" href="http://mrbird.cc/Oracle-SQLPlus命令.html"><span hidden itemprop="author" itemscope itemtype="http://schema.org/Person"><meta itemprop="name" content="MrBird"><meta itemprop="description" content=""><meta itemprop="image" content="/images/blogImage.jpg"></span><span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization"><meta itemprop="name" content="MrBird"></span><header class="post-header"><h1 class="post-title" itemprop="name headline">Oracle SQLPlus命令</h1><div class="post-meta"><span class="post-time"><span class="post-meta-item-icon"><i class="fa fa-calendar-o"></i> </span><span class="post-meta-item-text">Posted on</span> <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-11-01T20:23:48+08:00">2017-11-01 </time></span><span></span> <span class="post-meta-divider">|</span> <span class="page-pv"><i class="fa fa-laptop"></i>&nbsp;&nbsp;Visit count <span class="busuanzi-value" id="busuanzi_value_page_pv"></span></span></div></header><div class="post-body" itemprop="articleBody"><p>SQLPlus是一个被DBA和开发人员广泛使用的功能强大的Oracle工具，可以在各个平台上拥有操作的一致性。SQLPlus可以执行输入的SQL语句和SQL文件，通过SQLPlus可以和数据库进行对话。以下例子基于Oracle 11g。<a id="more"></a></p><h2 id="set命令设置运行环境"><a href="#set命令设置运行环境" class="headerlink" title="set命令设置运行环境"></a>set命令设置运行环境</h2><p>在Oracle 11g中，可以使用set命令来设置SQLPlus的运行环境。set命令语法如下：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">set</span> <span class="keyword">variable</span> <span class="keyword">value</span></span><br></pre></td></tr></table></figure><p><code>variable</code>为变量名，<code>value</code>为变量值。下面介绍几个常用的set变量。</p><h3 id="pagesize变量"><a href="#pagesize变量" class="headerlink" title="pagesize变量"></a>pagesize变量</h3><p>pagesize变量用来设置从顶部标题到页结束行（包含页首的空行）之间的行数。pagesize的默认值为14：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; show pagesize</span><br><span class="line">pagesize 14</span><br></pre></td></tr></table></figure><p></p><p>使用<code>set pagesize</code>命令修改一页的行数为18：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; set pagesize 18;</span><br><span class="line">SQL&gt; select user_id,username,account_status from dba_users;</span><br><span class="line"></span><br><span class="line">   USER_ID USERNAME                       ACCOUNT_STATUS</span><br><span class="line"><span class="comment">---------- ------------------------------ --------------------------------</span></span><br><span class="line">        74 MGMT_VIEW                      OPEN</span><br><span class="line">         0 SYS                            OPEN</span><br><span class="line">         5 SYSTEM                         OPEN</span><br><span class="line">        30 DBSNMP                         OPEN</span><br><span class="line">        72 SYSMAN                         OPEN</span><br><span class="line">        84 SCOTT                          OPEN</span><br><span class="line">         9 OUTLN                          EXPIRED &amp; LOCKED</span><br><span class="line">        75 FLOWS_FILES                    EXPIRED &amp; LOCKED</span><br><span class="line">        57 MDSYS                          EXPIRED &amp; LOCKED</span><br><span class="line">        53 ORDSYS                         EXPIRED &amp; LOCKED</span><br><span class="line">        42 EXFSYS                         EXPIRED &amp; LOCKED</span><br><span class="line">        32 WMSYS                          EXPIRED &amp; LOCKED</span><br><span class="line">        31 APPQOSSYS                      EXPIRED &amp; LOCKED</span><br><span class="line">        78 APEX_030200                    EXPIRED &amp; LOCKED</span><br><span class="line">        83 OWBSYS_AUDIT                   EXPIRED &amp; LOCKED</span><br></pre></td></tr></table></figure><p></p><p>可手动数一下是不是18行(lll￢ω￢)。</p><h3 id="newpage变量"><a href="#newpage变量" class="headerlink" title="newpage变量"></a>newpage变量</h3><p>该变量用于设置一页中空行的数量，默认值为1，可以使用<code>set newpage</code>命令改变该值：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; show newpage</span><br><span class="line">newpage 1</span><br><span class="line">SQL&gt; set newpage 5</span><br><span class="line">SQL&gt; select user_id,username,account_status from dba_users;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">   USER_ID USERNAME                       ACCOUNT_STATUS</span><br><span class="line"><span class="comment">---------- ------------------------------ --------------------------------</span></span><br><span class="line">        74 MGMT_VIEW                      OPEN</span><br><span class="line">         0 SYS                            OPEN</span><br><span class="line">         5 SYSTEM                         OPEN</span><br><span class="line">        30 DBSNMP                         OPEN</span><br><span class="line">        72 SYSMAN                         OPEN</span><br><span class="line">        84 SCOTT                          OPEN</span><br><span class="line">         9 OUTLN                          EXPIRED &amp; LOCKED</span><br><span class="line">        75 FLOWS_FILES                    EXPIRED &amp; LOCKED</span><br><span class="line">        57 MDSYS                          EXPIRED &amp; LOCKED</span><br><span class="line">        53 ORDSYS                         EXPIRED &amp; LOCKED</span><br><span class="line">        42 EXFSYS                         EXPIRED &amp; LOCKED</span><br></pre></td></tr></table></figure><p></p><h3 id="linesize变量"><a href="#linesize变量" class="headerlink" title="linesize变量"></a>linesize变量</h3><p>该变量用于设置SQLPlus环境中一行所显示的最多字符总数，默认值为80，当pagesize过小时，数据就会出现折行显示的情况。可以使用<code>set linesize</code>命令来调整linesize的值：</p><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; show linesize</span><br><span class="line">linesize 80</span><br><span class="line">SQL&gt; set linesize 120</span><br></pre></td></tr></table></figure><p></p><h3 id="pause变量"><a href="#pause变量" class="headerlink" title="pause变量"></a>pause变量</h3><p>用于设置输出结果翻页时，是否暂停，基本语法如下：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">set</span> pause <span class="keyword">value</span></span><br></pre></td></tr></table></figure><p></p><p>value可取的值有：</p><ul><li><p><code>off</code>，默认值，返回结果一次性输出完毕，中间翻页不会暂停；</p></li><li><p><code>on</code>，表示输出结果的每一页都暂停，用户按ENTER继续；</p></li><li><p><code>text</code>，在设置为on之后，继续设置text的值，用于暂停时显示；</p></li></ul><p>比如：</p><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; set pause on</span><br><span class="line">SQL&gt; set pause '按&lt;enter&gt;键继续'</span><br><span class="line">SQL&gt; select user_id,username,account_status from dba_users;</span><br><span class="line">按&lt;enter&gt;键继续</span><br><span class="line"></span><br><span class="line">   USER_ID USERNAME                       ACCOUNT_STATUS</span><br><span class="line"><span class="comment">---------- ------------------------------ --------------------------------</span></span><br><span class="line">        74 MGMT_VIEW                      OPEN</span><br><span class="line">         0 SYS                            OPEN</span><br><span class="line">         5 SYSTEM                         OPEN</span><br><span class="line">        30 DBSNMP                         OPEN</span><br><span class="line">        72 SYSMAN                         OPEN</span><br><span class="line">        84 SCOTT                          OPEN</span><br><span class="line">         9 OUTLN                          EXPIRED &amp; LOCKED</span><br><span class="line">        75 FLOWS_FILES                    EXPIRED &amp; LOCKED</span><br><span class="line">        57 MDSYS                          EXPIRED &amp; LOCKED</span><br><span class="line">        53 ORDSYS                         EXPIRED &amp; LOCKED</span><br><span class="line">        42 EXFSYS                         EXPIRED &amp; LOCKED</span><br><span class="line">        32 WMSYS                          EXPIRED &amp; LOCKED</span><br><span class="line">        31 APPQOSSYS                      EXPIRED &amp; LOCKED</span><br><span class="line">        78 APEX_030200                    EXPIRED &amp; LOCKED</span><br><span class="line">        83 OWBSYS_AUDIT                   EXPIRED &amp; LOCKED</span><br><span class="line">按&lt;enter&gt;键继续</span><br></pre></td></tr></table></figure><p></p><h3 id="numformat变量"><a href="#numformat变量" class="headerlink" title="numformat变量"></a>numformat变量</h3><p>该变量值用于设置显示数值的默认格式，基本语法如下：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">set</span> numformat <span class="keyword">format</span></span><br></pre></td></tr></table></figure><p></p><p>format为数值掩码，常用值及其说明如下：</p><table><tr><th>掩码</th><th>说明</th><th>举例</th></tr><tr><td>9</td><td>查询结果中数字替换格式的掩码</td><td>999</td></tr><tr><td>0</td><td>格式中的掩码屏蔽掉查询结果中的数字</td><td>999.00</td></tr><tr><td>$</td><td>在查询结果中的数字前添加美元前缀</td><td>$999</td></tr><tr><td>S</td><td>为数字显示符号类型，通常用于显示查询结果中的正负数字</td><td>S999</td></tr><tr><td>,</td><td>在字符<code>,</code>位置上放置都逗号/td&gt;</td><td>999,99</td></tr></table><p>查看scott.emp表中的SAL字段值，然后使用”$999,999,999.00”格式显示:</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; select ename,job,sal from scott.emp;</span><br><span class="line"></span><br><span class="line">ENAME      JOB              SAL</span><br><span class="line"><span class="comment">---------- --------- ----------</span></span><br><span class="line">SMITH      CLERK            800</span><br><span class="line">ALLEN      SALESMAN        1600</span><br><span class="line">WARD       SALESMAN        1250</span><br><span class="line">JONES      MANAGER         2975</span><br><span class="line">MARTIN     SALESMAN        1250</span><br><span class="line">BLAKE      MANAGER         2850</span><br><span class="line">CLARK      MANAGER         2450</span><br><span class="line">SCOTT      ANALYST         3000</span><br><span class="line">KING       PRESIDENT       5000</span><br><span class="line">TURNER     SALESMAN        1500</span><br><span class="line">ADAMS      CLERK           1100</span><br><span class="line">SQL&gt; set numformat $999,999,999.00</span><br><span class="line">SQL&gt; select ename,job,sal from scott.emp;</span><br><span class="line"></span><br><span class="line">ENAME      JOB                    SAL</span><br><span class="line"><span class="comment">---------- --------- ----------------</span></span><br><span class="line">SMITH      CLERK              $800.00</span><br><span class="line">ALLEN      SALESMAN         $1,600.00</span><br><span class="line">WARD       SALESMAN         $1,250.00</span><br><span class="line">JONES      MANAGER          $2,975.00</span><br><span class="line">MARTIN     SALESMAN         $1,250.00</span><br><span class="line">BLAKE      MANAGER          $2,850.00</span><br><span class="line">CLARK      MANAGER          $2,450.00</span><br><span class="line">SCOTT      ANALYST          $3,000.00</span><br><span class="line">KING       PRESIDENT        $5,000.00</span><br><span class="line">TURNER     SALESMAN         $1,500.00</span><br><span class="line">ADAMS      CLERK            $1,100.00</span><br></pre></td></tr></table></figure><p></p><h3 id="timing变量"><a href="#timing变量" class="headerlink" title="timing变量"></a>timing变量</h3><p>该变量用于显示执行SQL语句所花的时间，默认值为off：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; set timing on</span><br><span class="line">SQL&gt; select ename,job,sal from scott.emp;</span><br><span class="line"></span><br><span class="line">ENAME      JOB                    SAL</span><br><span class="line"><span class="comment">---------- --------- ----------------</span></span><br><span class="line">SMITH      CLERK              $800.00</span><br><span class="line">ALLEN      SALESMAN         $1,600.00</span><br><span class="line">WARD       SALESMAN         $1,250.00</span><br><span class="line">JONES      MANAGER          $2,975.00</span><br><span class="line">MARTIN     SALESMAN         $1,250.00</span><br><span class="line">BLAKE      MANAGER          $2,850.00</span><br><span class="line">CLARK      MANAGER          $2,450.00</span><br><span class="line">SCOTT      ANALYST          $3,000.00</span><br><span class="line">KING       PRESIDENT        $5,000.00</span><br><span class="line">TURNER     SALESMAN         $1,500.00</span><br><span class="line">ADAMS      CLERK            $1,100.00</span><br><span class="line"></span><br><span class="line">ENAME      JOB                    SAL</span><br><span class="line"><span class="comment">---------- --------- ----------------</span></span><br><span class="line">JAMES      CLERK              $950.00</span><br><span class="line">FORD       ANALYST          $3,000.00</span><br><span class="line">MILLER     CLERK            $1,300.00</span><br><span class="line"></span><br><span class="line">已选择14行。</span><br><span class="line"></span><br><span class="line">已用时间:  00: 00: 00.04</span><br></pre></td></tr></table></figure><p></p><p>set命令还有很多变量可用，可使用<code>help set</code>命令来查看。</p><h2 id="常用SQLPlus命令"><a href="#常用SQLPlus命令" class="headerlink" title="常用SQLPlus命令"></a>常用SQLPlus命令</h2><h3 id="help命令"><a href="#help命令" class="headerlink" title="help命令"></a>help命令</h3><p>help命令用来帮助用户查询指定命令详细介绍，类似于Linux的man，其的语法如下：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">help</span>|? [topic]</span><br></pre></td></tr></table></figure><p></p><p><code>?</code>表示一个命令的部分字符，用于模糊查询；topic参数表示要查询的命令的完整名称。如果直接输入help，则显示的是命令本身的详细信息：</p><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; help</span><br><span class="line"></span><br><span class="line"> <span class="keyword">HELP</span></span><br><span class="line"> <span class="comment">----</span></span><br><span class="line"></span><br><span class="line"> Accesses this command line <span class="keyword">help</span> system. Enter <span class="keyword">HELP</span> <span class="keyword">INDEX</span> <span class="keyword">or</span> ? <span class="keyword">INDEX</span></span><br><span class="line"> <span class="keyword">for</span> a <span class="keyword">list</span> <span class="keyword">of</span> topics.</span><br><span class="line"></span><br><span class="line"> You can <span class="keyword">view</span> <span class="keyword">SQL</span>*Plus resources <span class="keyword">at</span></span><br><span class="line">     <span class="keyword">http</span>://www.oracle.com/technology/tech/sql_plus/</span><br><span class="line"> <span class="keyword">and</span> the <span class="keyword">Oracle</span> <span class="keyword">Database</span> <span class="keyword">Library</span> <span class="keyword">at</span></span><br><span class="line">     <span class="keyword">http</span>://www.oracle.com/technology/documentation/</span><br><span class="line"></span><br><span class="line"> <span class="keyword">HELP</span>|? [topic]</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">SQL</span>&gt; <span class="keyword">help</span> <span class="keyword">set</span></span><br><span class="line"></span><br><span class="line"> <span class="keyword">SET</span></span><br><span class="line"> <span class="comment">---</span></span><br><span class="line"></span><br><span class="line"> <span class="keyword">Sets</span> a <span class="keyword">system</span> <span class="keyword">variable</span> <span class="keyword">to</span> <span class="keyword">alter</span> the <span class="keyword">SQL</span>*Plus environment <span class="keyword">settings</span></span><br><span class="line"> <span class="keyword">for</span> your <span class="keyword">current</span> session. <span class="keyword">For</span> example, <span class="keyword">to</span>:</span><br><span class="line">     -   <span class="keyword">set</span> the display width <span class="keyword">for</span> <span class="keyword">data</span></span><br><span class="line">     -   customize HTML formatting</span><br><span class="line">     -   <span class="keyword">enable</span> <span class="keyword">or</span> <span class="keyword">disable</span> printing <span class="keyword">of</span> <span class="keyword">column</span> headings</span><br><span class="line">     -   <span class="keyword">set</span> the <span class="built_in">number</span> <span class="keyword">of</span> <span class="keyword">lines</span> per page</span><br><span class="line"></span><br><span class="line"> <span class="keyword">SET</span> system_variable <span class="keyword">value</span></span><br><span class="line"></span><br><span class="line"> <span class="keyword">where</span> system_variable <span class="keyword">and</span> <span class="keyword">value</span> represent one <span class="keyword">of</span> the <span class="keyword">following</span> clauses:</span><br><span class="line"></span><br><span class="line">   APPI[NFO]&#123;<span class="keyword">OFF</span>|<span class="keyword">ON</span>|<span class="built_in">text</span>&#125;                   NEWP[AGE] &#123;<span class="number">1</span>|n|<span class="keyword">NONE</span>&#125;</span><br><span class="line">   <span class="built_in">ARRAY</span>[<span class="keyword">SIZE</span>] &#123;<span class="number">15</span>|n&#125;                       <span class="literal">NULL</span> <span class="built_in">text</span></span><br><span class="line">   <span class="keyword">AUTO</span>[<span class="keyword">COMMIT</span>] &#123;<span class="keyword">OFF</span>|<span class="keyword">ON</span>|IMM[EDIATE]|n&#125;      NUMF[ORMAT] <span class="keyword">format</span></span><br><span class="line">   AUTOP[RINT] &#123;<span class="keyword">OFF</span>|<span class="keyword">ON</span>&#125;                     <span class="keyword">NUM</span>[WIDTH] &#123;<span class="number">10</span>|n&#125;</span><br><span class="line">   AUTORECOVERY &#123;<span class="keyword">OFF</span>|<span class="keyword">ON</span>&#125;                    PAGES[IZE] &#123;<span class="number">14</span>|n&#125;</span><br><span class="line">   AUTOT[RACE] &#123;<span class="keyword">OFF</span>|<span class="keyword">ON</span>|<span class="keyword">TRACE</span>[<span class="keyword">ONLY</span>]&#125;         PAU[SE] &#123;<span class="keyword">OFF</span>|<span class="keyword">ON</span>|<span class="built_in">text</span>&#125;</span><br><span class="line">     [<span class="keyword">EXP</span>[LAIN]] [STAT[ISTICS]]             RECSEP &#123;WR[APPED]|EA[CH]|<span class="keyword">OFF</span>&#125;</span><br><span class="line">   BLO[CKTERMINATOR] &#123;.|c|<span class="keyword">ON</span>|<span class="keyword">OFF</span>&#125;           RECSEPCHAR &#123;_|c&#125;</span><br><span class="line">   CMDS[EP] &#123;;|c|OFF|ON&#125;                    SERVEROUT[PUT] &#123;ON|OFF&#125;</span><br><span class="line">   COLSEP &#123;_|text&#125;                            [SIZE &#123;n | UNLIMITED&#125;]</span><br><span class="line">   CON[CAT] &#123;.|c|ON|OFF&#125;                      [FOR[MAT]  &#123;WRA[PPED] |</span><br><span class="line">   COPYC[OMMIT] &#123;0|n&#125;                          WOR[D_WRAPPED] |</span><br><span class="line">   COPYTYPECHECK &#123;ON|OFF&#125;                      TRU[NCATED]&#125;]</span><br><span class="line">   DEF[INE] &#123;&amp;|c|ON|OFF&#125;                    SHIFT[INOUT] &#123;VIS[IBLE] |</span><br><span class="line">   <span class="keyword">DESCRIBE</span> [<span class="keyword">DEPTH</span> &#123;<span class="number">1</span>|n|ALL&#125;]                 INV[ISIBLE]&#125;</span><br><span class="line">     [LINENUM &#123;<span class="keyword">OFF</span>|<span class="keyword">ON</span>&#125;] [INDENT &#123;<span class="keyword">OFF</span>|<span class="keyword">ON</span>&#125;]   <span class="keyword">SHOW</span>[<span class="keyword">MODE</span>] &#123;<span class="keyword">OFF</span>|<span class="keyword">ON</span>&#125;</span><br><span class="line">   ECHO &#123;<span class="keyword">OFF</span>|<span class="keyword">ON</span>&#125;                            SQLBL[ANKLINES] &#123;<span class="keyword">OFF</span>|<span class="keyword">ON</span>&#125;</span><br><span class="line">   EDITF[ILE] file_name[.ext]               SQLC[ASE] &#123;MIX[ED] |</span><br><span class="line">   EMB[EDDED] &#123;<span class="keyword">OFF</span>|<span class="keyword">ON</span>&#125;                        LO[WER] | UP[PER]&#125;</span><br><span class="line">   ERRORL[OGGING] &#123;<span class="keyword">ON</span>|<span class="keyword">OFF</span>&#125;                  SQLCO[NTINUE] &#123;&gt; | <span class="built_in">text</span>&#125;</span><br><span class="line">     [<span class="keyword">TABLE</span> [schema.]tablename]             SQLN[UMBER] &#123;<span class="keyword">ON</span>|<span class="keyword">OFF</span>&#125;</span><br><span class="line">     [<span class="keyword">TRUNCATE</span>] [IDENTIFIER identifier]     SQLPLUSCOMPAT[IBILITY] &#123;x.y[.z]&#125;</span><br><span class="line">   ESC[APE] &#123;\|c|<span class="keyword">OFF</span>|<span class="keyword">ON</span>&#125;                    SQLPRE[FIX] &#123;<span class="comment">#|c&#125;</span></span><br><span class="line">   ESCCHAR &#123;@|?|%|$|<span class="keyword">OFF</span>&#125;                    SQLP[ROMPT] &#123;<span class="keyword">SQL</span>&gt;|<span class="built_in">text</span>&#125;</span><br><span class="line">   EXITC[OMMIT] &#123;ON|OFF&#125;                    SQLT[ERMINATOR] &#123;;|c|ON|OFF&#125;</span><br><span class="line">   FEED[BACK] &#123;6|n|ON|OFF&#125;                  SUF[FIX] &#123;SQL|text&#125;</span><br><span class="line">   FLAGGER &#123;OFF|ENTRY|INTERMED[IATE]|FULL&#125;  TAB &#123;ON|OFF&#125;</span><br><span class="line">   FLU[SH] &#123;ON|OFF&#125;                         TERM[OUT] &#123;ON|OFF&#125;</span><br><span class="line">   HEA[DING] &#123;ON|OFF&#125;                       TI[ME] &#123;OFF|ON&#125;</span><br><span class="line">   HEADS[EP] &#123;||c|ON|OFF&#125;                   TIMI[NG] &#123;OFF|ON&#125;</span><br><span class="line">   INSTANCE [instance_path|LOCAL]           TRIM[OUT] &#123;ON|OFF&#125;</span><br><span class="line">   LIN[ESIZE] &#123;80|n&#125;                        TRIMS[POOL] &#123;OFF|ON&#125;</span><br><span class="line">   LOBOF[FSET] &#123;1|n&#125;                        UND[ERLINE] &#123;-|c|ON|OFF&#125;</span><br><span class="line">   LOGSOURCE [pathname]                     VER[IFY] &#123;ON|OFF&#125;</span><br><span class="line">   LONG &#123;80|n&#125;                              WRA[P] &#123;ON|OFF&#125;</span><br><span class="line">   LONGC[HUNKSIZE] &#123;80|n&#125;                   XQUERY &#123;BASEURI text|</span><br><span class="line">   MARK[UP] HTML [OFF|ON]                     ORDERING&#123;UNORDERED|</span><br><span class="line">     [HEAD text] [BODY text] [TABLE text]              ORDERED|DEFAULT&#125;|</span><br><span class="line">     [ENTMAP &#123;ON|OFF&#125;]                        NODE&#123;BYVALUE|BYREFERENCE|</span><br><span class="line">     [SPOOL &#123;OFF|ON&#125;]                              DEFAULT&#125;|</span><br><span class="line">     [PRE[FORMAT] &#123;OFF|ON&#125;]                   CONTEXT text&#125;</span><br></pre></td></tr></table></figure><p></p><p>也可以使用<code>help index</code>命令查看SQLPlus命令清单：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; help index</span><br><span class="line"></span><br><span class="line">Enter <span class="keyword">Help</span> [topic] <span class="keyword">for</span> help.</span><br><span class="line"></span><br><span class="line"> @             COPY         PAUSE                    <span class="keyword">SHUTDOWN</span></span><br><span class="line"> @@            <span class="keyword">DEFINE</span>       PRINT                    SPOOL</span><br><span class="line"> /             DEL          <span class="keyword">PROMPT</span>                   SQLPLUS</span><br><span class="line"> <span class="keyword">ACCEPT</span>        <span class="keyword">DESCRIBE</span>     QUIT                     <span class="keyword">START</span></span><br><span class="line"> APPEND        <span class="keyword">DISCONNECT</span>   <span class="keyword">RECOVER</span>                  <span class="keyword">STARTUP</span></span><br><span class="line"> <span class="keyword">ARCHIVE</span> <span class="keyword">LOG</span>   EDIT         REMARK                   <span class="keyword">STORE</span></span><br><span class="line"> <span class="keyword">ATTRIBUTE</span>     <span class="keyword">EXECUTE</span>      REPFOOTER                TIMING</span><br><span class="line"> BREAK         <span class="keyword">EXIT</span>         REPHEADER                TTITLE</span><br><span class="line"> BTITLE        <span class="keyword">GET</span>          RESERVED WORDS (<span class="keyword">SQL</span>)     UNDEFINE</span><br><span class="line"> <span class="keyword">CHANGE</span>        <span class="keyword">HELP</span>         RESERVED WORDS (PL/<span class="keyword">SQL</span>)  <span class="keyword">VARIABLE</span></span><br><span class="line"> <span class="keyword">CLEAR</span>         HOST         RUN                      <span class="keyword">WHENEVER</span> OSERROR</span><br><span class="line"> <span class="keyword">COLUMN</span>        <span class="keyword">INPUT</span>        <span class="keyword">SAVE</span>                     <span class="keyword">WHENEVER</span> <span class="keyword">SQLERROR</span></span><br><span class="line"> <span class="keyword">COMPUTE</span>       <span class="keyword">LIST</span>         <span class="keyword">SET</span>                      XQUERY</span><br><span class="line"> <span class="keyword">CONNECT</span>       <span class="keyword">PASSWORD</span>     <span class="keyword">SHOW</span></span><br></pre></td></tr></table></figure><p></p><h3 id="describe命令"><a href="#describe命令" class="headerlink" title="describe命令"></a>describe命令</h3><p>该命令用于查询指定数据表的组成结构，语法如下：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">desc[ribe] object_name</span><br></pre></td></tr></table></figure><p></p><p>describe可缩写为desc。</p><p>比如查询scott.emp表中SALESMAN的编号，姓名和工资，过程中，使用<code>#desc scott.emp</code>命令查询scott.emp表中工资字段的名称：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; select empno,ename,</span><br><span class="line">  2  <span class="comment">#desc scott.emp</span></span><br><span class="line"> 名称                                      是否为空? 类型</span><br><span class="line"> <span class="comment">----------------------------------------- -------- ----------------------------</span></span><br><span class="line"> EMPNO                                     NOT NULL NUMBER(4)</span><br><span class="line"> ENAME                                              VARCHAR2(10)</span><br><span class="line"> JOB                                                VARCHAR2(9)</span><br><span class="line"> MGR                                                NUMBER(4)</span><br><span class="line"> HIREDATE                                           DATE</span><br><span class="line"> SAL                                                NUMBER(7,2)</span><br><span class="line"> COMM                                               NUMBER(7,2)</span><br><span class="line"> DEPTNO                                             NUMBER(2)</span><br><span class="line"></span><br><span class="line">  2  sal from scott.emp where job = 'SALESMAN';</span><br><span class="line"></span><br><span class="line">     EMPNO ENAME             SAL</span><br><span class="line"><span class="comment">---------- ---------- ----------</span></span><br><span class="line">      7499 ALLEN            1600</span><br><span class="line">      7521 WARD             1250</span><br><span class="line">      7654 MARTIN           1250</span><br><span class="line">      7844 TURNER           1500</span><br></pre></td></tr></table></figure><p></p><h3 id="spool命令"><a href="#spool命令" class="headerlink" title="spool命令"></a>spool命令</h3><p>该命令可以将查询结果输出到指定文件中，spool的语法格式如下：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">spo[ol] [file_name[.ext] [CRE[ATE] | REP[LACE] | APP[<span class="keyword">END</span>]] | <span class="keyword">OFF</span> | <span class="keyword">OUT</span>]</span><br></pre></td></tr></table></figure><p></p><ul><li><p><code>cre[ate]</code>，表示创建一个新的文件，默认值；</p></li><li><p><code>rep[lace]</code>，表示覆盖已存在的文件；</p></li><li><p><code>app[end]</code>，表示追加到一个已存在的文件中；</p></li><li><p><code>off|out</code>，表示关闭spool输出。</p></li></ul><p>比如：</p><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; spool d:\emp.txt</span><br><span class="line">SQL&gt; select empno,ename,job,sal from scott.emp;</span><br><span class="line"></span><br><span class="line">     EMPNO ENAME      JOB              SAL</span><br><span class="line"><span class="comment">---------- ---------- --------- ----------</span></span><br><span class="line">      7369 SMITH      CLERK            800</span><br><span class="line">      7499 ALLEN      SALESMAN        1600</span><br><span class="line">      7521 WARD       SALESMAN        1250</span><br><span class="line">      7566 JONES      MANAGER         2975</span><br><span class="line">      7654 MARTIN     SALESMAN        1250</span><br><span class="line">      7698 BLAKE      MANAGER         2850</span><br><span class="line">      7782 CLARK      MANAGER         2450</span><br><span class="line">      7788 SCOTT      ANALYST         3000</span><br><span class="line">      7839 KING       PRESIDENT       5000</span><br><span class="line">      7844 TURNER     SALESMAN        1500</span><br><span class="line">      7876 ADAMS      CLERK           1100</span><br><span class="line"></span><br><span class="line">     EMPNO ENAME      JOB              SAL</span><br><span class="line"><span class="comment">---------- ---------- --------- ----------</span></span><br><span class="line">      7900 JAMES      CLERK            950</span><br><span class="line">      7902 FORD       ANALYST         3000</span><br><span class="line">      7934 MILLER     CLERK           1300</span><br><span class="line"></span><br><span class="line">已选择14行。</span><br><span class="line"></span><br><span class="line">SQL&gt; spool off</span><br></pre></td></tr></table></figure><p></p><p>到D盘打开emp.txt如下：</p><p><img src="img/mrbird_photo_20171105144257.png" alt="mrbird_photo_20171105144257.png"></p><h3 id="define命令"><a href="#define命令" class="headerlink" title="define命令"></a>define命令</h3><p>该命令用来定义一个变量并赋值，基本语法如下：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">def[ine] [variable] | [variable = text]</span><br></pre></td></tr></table></figure><p></p><p>比如：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; define vjob='SALESMAN'</span><br><span class="line">SQL&gt; define vjob</span><br><span class="line">DEFINE VJOB            = "SALESMAN" (CHAR)</span><br></pre></td></tr></table></figure><p></p><h3 id="show命令"><a href="#show命令" class="headerlink" title="show命令"></a>show命令</h3><p>show命令用来显示SQLPlus系统变量的值，语法如下：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sho[w] option</span><br></pre></td></tr></table></figure><p></p><p>option表示要显示的系统选项，常用的值有：all，parameters [parameter_name]，sga，spool和user等。</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; show parameters db_block_size</span><br><span class="line"></span><br><span class="line">NAME                                 TYPE        VALUE</span><br><span class="line"><span class="comment">------------------------------------ ----------- ------------------------------</span></span><br><span class="line">db_block_size                        integer     8192</span><br><span class="line">SQL&gt; show sga</span><br><span class="line"></span><br><span class="line">Total System Global Area 3373858816 bytes</span><br><span class="line">Fixed Size                  2180424 bytes</span><br><span class="line">Variable Size            1862273720 bytes</span><br><span class="line">Database Buffers         1493172224 bytes</span><br><span class="line">Redo Buffers               16232448 bytes</span><br><span class="line">SQL&gt; show user</span><br><span class="line">USER 为 "SYSTEM"</span><br></pre></td></tr></table></figure><p></p><h3 id="save命令"><a href="#save命令" class="headerlink" title="save命令"></a>save命令</h3><p>该命令将SQL缓冲区的最近一条SQL或PL/SQL块保存到指定的文件中，语法如下：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sav[e] [FILE] file_name[.ext] [CRE[ATE] | REP[LACE] | APP[<span class="keyword">END</span>]]</span><br></pre></td></tr></table></figure><p></p><p>比如：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; select * from scott.dept;</span><br><span class="line"></span><br><span class="line">    DEPTNO DNAME          LOC</span><br><span class="line"><span class="comment">---------- -------------- -------------</span></span><br><span class="line">        10 ACCOUNTING     NEW YORK</span><br><span class="line">        20 RESEARCH       DALLAS</span><br><span class="line">        30 SALES          CHICAGO</span><br><span class="line">        40 OPERATIONS     BOSTON</span><br><span class="line"></span><br><span class="line">SQL&gt; save d:\dept.sql</span><br><span class="line">已创建 file d:\dept.sql</span><br></pre></td></tr></table></figure><p></p><p>如果不指定文件扩展名，默认为.sql。</p><h3 id="get命令"><a href="#get命令" class="headerlink" title="get命令"></a>get命令</h3><p>该命令将一个SQL脚本文件的内容放进SQL的缓冲区，语法格式如下：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">get [FILE] file_name[.ext] [LIST | NOLIST]</span><br></pre></td></tr></table></figure><p></p><p>其中list表示加载到缓冲区的时候显示文件的内容，nolist则表示不显示。</p><p>比如加载d:\dept.sql到SQL缓冲区，并运行命令<code>/</code>执行该语句：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; get d:\dept.sql list</span><br><span class="line">  1* select * from scott.dept</span><br><span class="line">SQL&gt; /</span><br><span class="line"></span><br><span class="line">    DEPTNO DNAME          LOC</span><br><span class="line"><span class="comment">---------- -------------- -------------</span></span><br><span class="line">        10 ACCOUNTING     NEW YORK</span><br><span class="line">        20 RESEARCH       DALLAS</span><br><span class="line">        30 SALES          CHICAGO</span><br><span class="line">        40 OPERATIONS     BOSTON</span><br></pre></td></tr></table></figure><p></p><h3 id="start和"><a href="#start和" class="headerlink" title="start和@"></a>start和@</h3><p>两个命令都是用于执行一个sql脚本文件，比如：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; start d:\dept.sql</span><br><span class="line"></span><br><span class="line">    DEPTNO DNAME          LOC</span><br><span class="line"><span class="comment">---------- -------------- -------------</span></span><br><span class="line">        10 ACCOUNTING     NEW YORK</span><br><span class="line">        20 RESEARCH       DALLAS</span><br><span class="line">        30 SALES          CHICAGO</span><br><span class="line">        40 OPERATIONS     BOSTON</span><br><span class="line"></span><br><span class="line">SQL&gt; @ d:\dept.sql</span><br><span class="line"></span><br><span class="line">    DEPTNO DNAME          LOC</span><br><span class="line"><span class="comment">---------- -------------- -------------</span></span><br><span class="line">        10 ACCOUNTING     NEW YORK</span><br><span class="line">        20 RESEARCH       DALLAS</span><br><span class="line">        30 SALES          CHICAGO</span><br><span class="line">        40 OPERATIONS     BOSTON</span><br></pre></td></tr></table></figure><p></p><h2 id="格式化查询结果"><a href="#格式化查询结果" class="headerlink" title="格式化查询结果"></a>格式化查询结果</h2><h3 id="column"><a href="#column" class="headerlink" title="column"></a>column</h3><p>该命令可以实现格式化查询结果，设置列宽，设置列标题等。语法如下：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">col[umn] [column_name|alias|option]</span><br></pre></td></tr></table></figure><p></p><p><code>column_name</code>用于指定要设置的列的名称，<code>alias</code>用于指定列的别名，<code>option</code>用于指定列的显示格式，其值和说明如下表所示：</p><table><tr><th>option选项的值</th><th>说明</th></tr><tr><td>clear</td><td>清除指定列所设置的格式，恢复默认值</td></tr><tr><td>format</td><td>格式化指定列</td></tr><tr><td>heading</td><td>指定列标题</td></tr><tr><td>justify</td><td>调整列标题的对齐方式，默认情况下：数值类型的右对齐，其他类型的左对齐</td></tr><tr><td>null</td><td>替换null值</td></tr><tr><td>print/noprint</td><td>显示列标题或隐藏列标题，默认为print</td></tr><tr><td>on/off</td><td>控制定义的显示属性状态，off表示定义的所有显示属性都不起作用</td></tr><tr><td>wrapped</td><td>当字符串的长度超过显示宽度时，将字符串的超出部分折叠到下一行显示</td></tr><tr><td>word_wrapped</td><td>表示从一个完整的字符处折叠</td></tr><tr><td>truncated</td><td>表示截取字符串尾部</td></tr></table><p><strong>format</strong>选项</p><p>使用format选项格式化scott.emp表中的sal列，格式为$999,999.00：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; column sal format $999,999.00</span><br><span class="line">SQL&gt; select empno,ename,sal from scott.emp;</span><br><span class="line"></span><br><span class="line">     EMPNO ENAME               SAL</span><br><span class="line"><span class="comment">---------- ---------- ------------</span></span><br><span class="line">      7369 SMITH           $800.00</span><br><span class="line">      7499 ALLEN         $1,600.00</span><br><span class="line">      7521 WARD          $1,250.00</span><br><span class="line">      7566 JONES         $2,975.00</span><br><span class="line">      7654 MARTIN        $1,250.00</span><br><span class="line">      7698 BLAKE         $2,850.00</span><br><span class="line">      7782 CLARK         $2,450.00</span><br><span class="line">      7788 SCOTT         $3,000.00</span><br><span class="line">      7839 KING          $5,000.00</span><br><span class="line">      7844 TURNER        $1,500.00</span><br><span class="line">      7876 ADAMS         $1,100.00</span><br><span class="line"></span><br><span class="line">     EMPNO ENAME               SAL</span><br><span class="line"><span class="comment">---------- ---------- ------------</span></span><br><span class="line">      7900 JAMES           $950.00</span><br><span class="line">      7902 FORD          $3,000.00</span><br><span class="line">      7934 MILLER        $1,300.00</span><br><span class="line"></span><br><span class="line">已选择14行。</span><br></pre></td></tr></table></figure><p></p><p><strong>heading</strong>选项</p><p>使用heading选项将scott.emp表的empno，ename和sal三个列名转换为中文：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; column empno heading 员工编号</span><br><span class="line">SQL&gt; column ename heading 员工姓名</span><br><span class="line">SQL&gt; column sal heading 工资</span><br><span class="line">SQL&gt; select empno,ename,sal from scott.emp;</span><br><span class="line"></span><br><span class="line">  员工编号 员工姓名           工资</span><br><span class="line"><span class="comment">---------- ---------- ------------</span></span><br><span class="line">      7369 SMITH           $800.00</span><br><span class="line">      7499 ALLEN         $1,600.00</span><br><span class="line">      7521 WARD          $1,250.00</span><br><span class="line">      7566 JONES         $2,975.00</span><br><span class="line">      7654 MARTIN        $1,250.00</span><br><span class="line">      7698 BLAKE         $2,850.00</span><br><span class="line">      7782 CLARK         $2,450.00</span><br><span class="line">      7788 SCOTT         $3,000.00</span><br><span class="line">      7839 KING          $5,000.00</span><br><span class="line">      7844 TURNER        $1,500.00</span><br><span class="line">      7876 ADAMS         $1,100.00</span><br><span class="line"></span><br><span class="line">  员工编号 员工姓名           工资</span><br><span class="line"><span class="comment">---------- ---------- ------------</span></span><br><span class="line">      7900 JAMES           $950.00</span><br><span class="line">      7902 FORD          $3,000.00</span><br><span class="line">      7934 MILLER        $1,300.00</span><br><span class="line"></span><br><span class="line">已选择14行。</span><br></pre></td></tr></table></figure><p></p><p><strong>null</strong>选项</p><p>使用null选项将scott.emp表中comm列值为null显示成“空值”：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; column comm null '空值'</span><br><span class="line">SQL&gt; select empno,ename,comm from scott.emp where comm is null;</span><br><span class="line"></span><br><span class="line">  员工编号 员工姓名         COMM</span><br><span class="line"><span class="comment">---------- ---------- ----------</span></span><br><span class="line">      7369 SMITH      空值</span><br><span class="line">      7566 JONES      空值</span><br><span class="line">      7698 BLAKE      空值</span><br><span class="line">      7782 CLARK      空值</span><br><span class="line">      7788 SCOTT      空值</span><br><span class="line">      7839 KING       空值</span><br><span class="line">      7876 ADAMS      空值</span><br><span class="line">      7900 JAMES      空值</span><br><span class="line">      7902 FORD       空值</span><br><span class="line">      7934 MILLER     空值</span><br><span class="line"></span><br><span class="line">已选择10行。</span><br></pre></td></tr></table></figure><p></p><p><strong>wrapped/word_wrapped</strong>选项</p><p>使用<strong>wrapped</strong>选项实现按照指定长度折行：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; create table test(</span><br><span class="line">  2  col1 varchar2(100)</span><br><span class="line">  3  );</span><br><span class="line"></span><br><span class="line">表已创建。</span><br><span class="line"></span><br><span class="line">SQL&gt; insert into test(col1) values ('HOW ARE YOU?');</span><br><span class="line"></span><br><span class="line">已创建 1 行。</span><br><span class="line"></span><br><span class="line">SQL&gt; select col1 from test;</span><br><span class="line"></span><br><span class="line">COL1</span><br><span class="line"><span class="comment">--------------------------------------------------------------------------------</span></span><br><span class="line">HOW ARE YOU?</span><br><span class="line"></span><br><span class="line">SQL&gt; column col1 format a5</span><br><span class="line">SQL&gt; column col1 wrapped</span><br><span class="line">SQL&gt; select col1 from test;</span><br><span class="line"></span><br><span class="line">COL1</span><br><span class="line"><span class="comment">-----</span></span><br><span class="line">HOW A</span><br><span class="line">RE YO</span><br><span class="line">U?</span><br></pre></td></tr></table></figure><p></p><p>使用<strong>word_wrapped</strong>选项按照完整字符串折行</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; column col1 word_wrapped</span><br><span class="line">SQL&gt; select col1 from test;</span><br><span class="line"></span><br><span class="line">COL1</span><br><span class="line"><span class="comment">-----</span></span><br><span class="line">HOW</span><br><span class="line">ARE</span><br><span class="line">YOU?</span><br></pre></td></tr></table></figure><p></p><h3 id="ttitle和btitle命令"><a href="#ttitle和btitle命令" class="headerlink" title="ttitle和btitle命令"></a>ttitle和btitle命令</h3><p>这两个命令分别用来设置打印时每页的页首和页脚标题，其中ttitle语法如下（btitle语法类似）：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">tti[tle] [printspec [text|variable] ...] | [OFF|ON]</span><br></pre></td></tr></table></figure><p></p><p><code>printspec</code>作为头标题的修饰性选项，其值和说明如下表所示：</p><table><tr><th>printspec选项的值</th><th>说明</th></tr><tr><td>col</td><td>指定当前行的第几列打印头标题</td></tr><tr><td>skip</td><td>跳到从下一行开始的第几行，默认为1</td></tr><tr><td>left</td><td>在当前行中左对齐打印数据</td></tr><tr><td>center</td><td>在当前行中间打印数据</td></tr><tr><td>right</td><td>在当前行中右对齐打印数据</td></tr><tr><td>bold</td><td>以黑体打印数据</td></tr></table><p>比如：打印输出scott.salgrade数据表中的记录，并设置标题：</p><figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">SQL&gt; set pagesize 8</span><br><span class="line">SQL&gt; ttitle left '销售情况排行表'</span><br><span class="line">SQL&gt; btitle left '打印日期2017年11月5日 打印人 MrBird'</span><br><span class="line">SQL&gt; select * from scott.salgrade;</span><br><span class="line"></span><br><span class="line">销售情况排行表</span><br><span class="line">     GRADE      LOSAL      HISAL</span><br><span class="line"><span class="comment">---------- ---------- ----------</span></span><br><span class="line">         1        700       1200</span><br><span class="line">         2       1201       1400</span><br><span class="line">         3       1401       2000</span><br><span class="line">打印日期2017年11月5日 打印人 MrBird</span><br><span class="line"></span><br><span class="line">销售情况排行表</span><br><span class="line">     GRADE      LOSAL      HISAL</span><br><span class="line"><span class="comment">---------- ---------- ----------</span></span><br><span class="line">         4       2001       3000</span><br><span class="line">         5       3001       9999</span><br><span class="line"></span><br><span class="line">打印日期2017年11月5日 打印人 MrBird</span><br></pre></td></tr></table></figure><p></p><script>$(".post-body a").not(".thispage").addClass("ignore-href").attr("target","_blank")</script></div><div></div><div><div style="padding:10px 0;margin:20px auto;width:90%;text-align:center;color:#878787"><div>请作者喝瓶肥宅水~</div><button id="rewardButton" style="margin-top:10px" disable="enable" onclick='var e=document.getElementById("QR");"none"===e.style.display?e.style.display="block":e.style.display="none"'><span style="height:46px;width:46px;line-height:46px;border-radius:50%;color:#fe5f55;font-weight:600;background:#ffd5be;border:none;box-shadow:0 4px 8px 0 rgba(255,213,190,.4)">￥</span></button><div id="QR" style="display:none"><div id="wechat" style="display:inline-block"><img id="wechat_qr" src="/img/wechat_pay.png" alt="MrBird WeChat Pay"></div><div id="alipay" style="display:inline-block"><img id="alipay_qr" src="/img/ali_pay.png" alt="MrBird Alipay"></div></div></div><style>#QR img{width:auto;margin:.8em 1em 0 1em}</style></div><div><ul class="post-copyright"><li class="post-copyright-author"><strong>本文作者：</strong> MrBird</li><li class="post-copyright-link"><strong>本文链接：</strong> <a href="http://mrbird.cc/Oracle-SQLPlus命令.html" title="Oracle SQLPlus命令">http://mrbird.cc/Oracle-SQLPlus命令.html</a></li><li class="post-copyright-license"><strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="external nofollow" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明出处！</li></ul></div><footer class="post-footer"><div class="post-tags" style="margin-bottom:1.3rem"><a href="/tags/DataBase/" rel="tag"># DataBase</a> <a href="/tags/Oracle/" rel="tag"># Oracle</a> <a href="/tags/Oracle-11g/" rel="tag"># Oracle 11g</a></div><div class="post-nav"><div class="post-nav-next post-nav-item"><a href="/Nginx-rewrite.html" rel="next" title="Nginx Rewrite"><i class="fa fa-chevron-left"></i> Nginx Rewrite</a></div><span class="post-nav-divider"></span><div class="post-nav-prev post-nav-item"><a href="/Oracle-PL-SQL编程.html" rel="prev" title="Oracle PL/SQL编程">Oracle PL/SQL编程 <i class="fa fa-chevron-right"></i></a></div></div></footer></article><hr><div id="container"></div><div class="post-spread"><div id="comment-div"></div><style>.valine .vlist{margin-bottom:3rem}.valine .vwrap .vcontrol .col.col-60{text-align:left}.valine .vlist .vcard .vhead,.valine .vlist .vcard section .vfooter{text-align:left}.valine .vlist .vcard section{padding-bottom:.5rem!important}.vname{color:#42b983!important}.valine .vinfo .col{text-align:left;margin-left:-27rem}div#comment-div{margin-bottom:-8rem}.valine .vlist .vcard .vcontent .code,.valine .vlist .vcard .vcontent code,.valine .vlist .vcard .vcontent pre{background:#fbfbfb}.valine .vlist .vcard .vcontent a{color:#42b983}.valine .vlist .vcard .vimg{border-radius:3px}.valine .vbtn{border-radius:2px;padding:.3rem 1.25rem}.valine .vbtn:active,.valine .vbtn:hover{color:#42b983;border-color:#42b983;background-color:#fff}.valine .vwrap .vheader .vinput:focus{border-bottom-color:#42b983}.valine .vlist .vcard .vcontent.expand:before{background:-webkit-gradient(linear,left top,left bottom,from(hsla(0,0%,100%,0)),to(hsla(0,0%,100%,.2)));background:linear-gradient(180deg,hsla(0,0%,100%,0),hsla(0,0%,100%,.2))}.valine .vlist .vcard .vcontent.expand:after{content:"点击展开";font-size:.4rem;text-align:right;left:-1rem;background:hsla(0,0%,100%,.2)}.valine .vlist .vcard section .vfooter .vat{color:#b3b3b3}.valine .vlist .vcard section .vfooter .vat:hover{color:#42b983}.vcontent img{margin:0}.valine .info{display:none}</style><script type="text/javascript" src="/js/av.min.js"></script><script type="text/javascript" src="/js/Valine.min.js"></script><script type="text/javascript" src="/js/activate-power-mode.js"></script><script>POWERMODE.colorful=!0,POWERMODE.shake=!1,document.body.addEventListener("input",POWERMODE),new Valine({el:"#comment-div",notify:!1,verify:!0,appId:"SMcDFP1bN1jgb9Lo8JmtICHm-gzGzoHsz",appKey:"dH4nrUrt3V5XiJiI6Qyejnbi",placeholder:"",path:window.location.pathname,avatar:"monsterid",guest_info:["nick","mail","link"]});var chicken='<a href="#"><img src="https://image.uisdc.com/wp-content/uploads/2018/06/uisdc-chat-chicken.gif" class="checken"></a>';$("#comment-div").prepend(chicken)</script></div></div><script>var $bqinline=$("img[alt='bq-inline']");$bqinline.css({width:"2.3rem",height:"2.3rem",display:"inline","vertical-align":"text-bottom"})</script></div><div class="comments" id="comments"></div></div><aside id="sidebar" class="sidebar" onselectstart="return!1"><div class="sidebar-inner"><ul class="sidebar-nav motion-element"><li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">Contents</li><li class="sidebar-nav-overview" data-target="site-overview">Site Preview</li></ul><section class="site-overview sidebar-panel"><div class="sidebar-sticky sticky"><div itemscope itemtype="http://schema.org/Person"><div class="author__avatar"><img src="/images/blogImage.jpg" class="author__avatar" alt="MrBird" itemprop="image"></div><div class="author__content"><h3 class="author__name" itemprop="name">MrBird's Blog</h3><p class="author__bio" itemprop="description">A simple blog, code repository, just keep blogging</p></div><div class="author__urls-wrapper"><button class="btn btn--inverse">Follow</button><ul class="author__urls social-icons"><li><a href="http://map.baidu.com/?newmap=1&s=s%26wd%3D%E7%A6%8F%E5%B7%9E%E5%B8%82%26c%3D300&from=alamap&tpl=mapcity" target="_blank" itemprop="url" class="ignore-href"><i class="fa fa-fw fa-map-marker" aria-hidden="true"></i>&nbsp;&nbsp;FuZhou,CN</a></li><li><a href="https://love.mrbird.cc" target="_blank" itemprop="url" class="ignore-href"><i class="fa fa-fw fa-diamond" aria-hidden="true"></i>&nbsp;&nbsp;Love</a></li><li><a href="https://cloud.mrbird.cn" target="_blank" itemprop="url" class="ignore-href"><i class="fa fa-fw fa-chain" aria-hidden="true"></i>&nbsp;&nbsp;FEBS</a></li><li><a href="/atom.xml" target="_blank" itemprop="url" class="ignore-href"><i class="fa fa-fw fa-rss" aria-hidden="true"></i>&nbsp;&nbsp;RSS</a></li><li><a href="https://gitee.com/mrbirdd" target="_blank" itemprop="sameAs" class="ignore-href"><i class="fa fa-fw fa-codepen" aria-hidden="true"></i>&nbsp;&nbsp;Gitee</a></li><li><a href="https://github.com/wuyouzhuguli" target="_blank" itemprop="sameAs" class="ignore-href"><i class="fa fa-fw fa-github-alt" aria-hidden="true"></i>&nbsp;&nbsp;GitHub</a></li><li><a href="javascript:;" class="popup-trigger"><i class="fa fa-fw fa-search" aria-hidden="true"></i>&nbsp;&nbsp;Search</a></li></ul></div></div></div><script>var $urls=$(".author__urls").find("a");$urls.each(function(){var o=$(this);o.mouseenter(function(){o.css({color:"#414547"})}),o.mouseleave(function(){o.css({color:""})})})</script></section><section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active"><div class="post-toc"><div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#set命令设置运行环境"><span class="nav-number">1.</span> <span class="nav-text">set命令设置运行环境</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#pagesize变量"><span class="nav-number">1.1.</span> <span class="nav-text">pagesize变量</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#newpage变量"><span class="nav-number">1.2.</span> <span class="nav-text">newpage变量</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#linesize变量"><span class="nav-number">1.3.</span> <span class="nav-text">linesize变量</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#pause变量"><span class="nav-number">1.4.</span> <span class="nav-text">pause变量</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#numformat变量"><span class="nav-number">1.5.</span> <span class="nav-text">numformat变量</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#timing变量"><span class="nav-number">1.6.</span> <span class="nav-text">timing变量</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#常用SQLPlus命令"><span class="nav-number">2.</span> <span class="nav-text">常用SQLPlus命令</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#help命令"><span class="nav-number">2.1.</span> <span class="nav-text">help命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#describe命令"><span class="nav-number">2.2.</span> <span class="nav-text">describe命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#spool命令"><span class="nav-number">2.3.</span> <span class="nav-text">spool命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#define命令"><span class="nav-number">2.4.</span> <span class="nav-text">define命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#show命令"><span class="nav-number">2.5.</span> <span class="nav-text">show命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#save命令"><span class="nav-number">2.6.</span> <span class="nav-text">save命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#get命令"><span class="nav-number">2.7.</span> <span class="nav-text">get命令</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#start和"><span class="nav-number">2.8.</span> <span class="nav-text">start和@</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#格式化查询结果"><span class="nav-number">3.</span> <span class="nav-text">格式化查询结果</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#column"><span class="nav-number">3.1.</span> <span class="nav-text">column</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#ttitle和btitle命令"><span class="nav-number">3.2.</span> <span class="nav-text">ttitle和btitle命令</span></a></li></ol></li></ol></div></div></section></div></aside></div></main><footer id="footer" class="footer" onselectstart="return!1"><div class="footer-inner"><div class="copyright">&copy; 2016 - <span itemprop="copyrightYear">2019</span>&nbsp;&nbsp; <span class="author" itemprop="copyrightHolder">MrBird</span>&nbsp;&nbsp;|<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>&nbsp;&nbsp;UV&nbsp;<span class="busuanzi-value" id="busuanzi_value_site_uv" style="cursor:pointer" title="统计开始时间：2019年7月5日"></span> &nbsp;&nbsp;PV&nbsp;<span class="busuanzi-value" id="busuanzi_value_site_pv" style="cursor:pointer" title="统计开始时间：2019年7月5日"></span></div></div></footer><div class="back-to-top"><span style="font-family:'Source Sans Pro','Helvetica Neue',Arial,sans-serif;font-size:1.2em;font-weight:600">TOP</span></div></div><script type="text/javascript">"[object Function]"!==Object.prototype.toString.call(window.Promise)&&(window.Promise=null)</script><script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script><script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script><script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script><script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script><script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script><script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script><script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script><script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script><script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script><script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script><script type="text/javascript">function proceedsearch(){$("body").append('<div class="search-popup-overlay local-search-pop-overlay"></div>').css("overflow","hidden"),$(".search-popup-overlay").click(onPopupClose),$(".popup").toggle();var t=$("#local-search-input");t.attr("autocapitalize","none"),t.attr("autocorrect","off"),t.focus()}var isfetched=!1,isXml=!0,search_path="search.xml";0===search_path.length?search_path="search.xml":search_path.endsWith("json")&&(isXml=!1);var path="/"+search_path,onPopupClose=function(t){$(".popup").hide(),$("#local-search-input").val(""),$(".search-result-list").remove(),$("#no-result").remove(),$(".local-search-pop-overlay").remove(),$("body").css("overflow","")},searchFunc=function(t,e,o){"use strict";$("body").append('<div class="search-popup-overlay local-search-pop-overlay"><div id="search-loading-icon"><i class="fa fa-spinner fa-pulse fa-2x fa-fw"></i></div></div>').css("overflow","hidden"),$("#search-loading-icon").css("margin","20% auto 0 auto").css("text-align","center"),$.ajax({url:t,dataType:isXml?"xml":"json",async:!0,success:function(t){isfetched=!0,$(".popup").detach().appendTo(".header-inner");var n=isXml?$("entry",t).map(function(){return{title:$("title",this).text(),content:$("content",this).text(),url:$("url",this).text()}}).get():t,r=document.getElementById(e),s=document.getElementById(o),a=function(){var t=r.value.trim().toLowerCase(),e=t.split(/[\s\-]+/);e.length>1&&e.push(t);var o=[];if(t.length>0&&n.forEach(function(n){function r(e,o,n,r){for(var s=r[r.length-1],a=s.position,i=s.word,l=[],h=0;a+i.length<=n&&0!=r.length;){i===t&&h++,l.push({position:a,length:i.length});var p=a+i.length;for(r.pop();0!=r.length&&(s=r[r.length-1],a=s.position,i=s.word,p>a);)r.pop()}return c+=h,{hits:l,start:o,end:n,searchTextCount:h}}function s(t,e){var o="",n=e.start;return e.hits.forEach(function(e){o+=t.substring(n,e.position);var r=e.position+e.length;o+='<b class="search-keyword">'+t.substring(e.position,r)+"</b>",n=r}),o+=t.substring(n,e.end)}var a=!1,i=0,c=0,l=n.title.trim(),h=l.toLowerCase(),p=n.content.trim().replace(/<[^>]+>/g,""),u=p.toLowerCase(),f=decodeURIComponent(n.url),d=[],g=[];if(""!=l&&(e.forEach(function(t){function e(t,e,o){var n=t.length;if(0===n)return[];var r=0,s=[],a=[];for(o||(e=e.toLowerCase(),t=t.toLowerCase());(s=e.indexOf(t,r))>-1;)a.push({position:s,word:t}),r=s+n;return a}d=d.concat(e(t,h,!1)),g=g.concat(e(t,u,!1))}),(d.length>0||g.length>0)&&(a=!0,i=d.length+g.length)),a){[d,g].forEach(function(t){t.sort(function(t,e){return e.position!==t.position?e.position-t.position:t.word.length-e.word.length})});var v=[];0!=d.length&&v.push(r(l,0,l.length,d));for(var C=[];0!=g.length;){var $=g[g.length-1],m=$.position,x=$.word,w=m-20,y=m+80;w<0&&(w=0),y<m+x.length&&(y=m+x.length),y>p.length&&(y=p.length),C.push(r(p,w,y,g))}C.sort(function(t,e){return t.searchTextCount!==e.searchTextCount?e.searchTextCount-t.searchTextCount:t.hits.length!==e.hits.length?e.hits.length-t.hits.length:t.start-e.start});var T=parseInt("1");T>=0&&(C=C.slice(0,T));var b="";b+=0!=v.length?"<li><a href='"+f+"' class='search-result-title'>"+s(l,v[0])+"</a>":"<li><a href='"+f+"' class='search-result-title'>"+l+"</a>",C.forEach(function(t){b+="<a href='"+f+'\'><p class="search-result">'+s(p,t)+"...</p></a>"}),b+="</li>",o.push({item:b,searchTextCount:c,hitCount:i,id:o.length})}}),1===e.length&&""===e[0])s.innerHTML='<div id="no-result"><i class="fa fa-search fa-5x" /></div>';else if(0===o.length)s.innerHTML='<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>';else{o.sort(function(t,e){return t.searchTextCount!==e.searchTextCount?e.searchTextCount-t.searchTextCount:t.hitCount!==e.hitCount?e.hitCount-t.hitCount:e.id-t.id});var a='<ul class="search-result-list">';o.forEach(function(t){a+=t.item}),a+="</ul>",s.innerHTML=a}};r.addEventListener("input",a),$(".local-search-pop-overlay").remove(),$("body").css("overflow",""),proceedsearch()}})};$(".popup-trigger").click(function(t){t.stopPropagation(),isfetched===!1?searchFunc(path,"local-search-input","local-search-result"):proceedsearch()}),$(".popup-btn-close").click(onPopupClose),$(".popup").click(function(t){t.stopPropagation()}),$(document).on("keyup",function(t){var e=27===t.which&&$(".search-popup").is(":visible");e&&onPopupClose()})</script></body><script>$(function(){$("a").not(".nav-link,.cloud-tie-join-count,.ignore-href,.jstree-anchor").addClass("animsition-link")});var burst1=new mojs.Burst({left:0,top:0,radius:{5:40},children:{shape:"circle",fill:["red","cyan","orange"],fillOpacity:.8,radiusX:3.5,radiusY:3.5}});document.addEventListener("click",function(a){null==a.target.href&&"footer"!=a.target.className&&"copyright"!=a.target.className&&"author__urls social-icons"!=a.target.className&&"author__avatar"!=a.target.className&&"sidebar sidebar-active"!=a.target.className&&burst1.tune({x:a.pageX,y:a.pageY}).generate().replay()})</script><script type="text/javascript" src="/js/message.js"></script></html><!-- rebuild by neat -->